package com.javaPro.myProject.modules.lishiyuanyuan.service.impl;

import com.javaPro.myProject.modules.lishiyuanyuan.dao.LishiyuanyuanDao;
import com.javaPro.myProject.modules.lishiyuanyuan.entity.Lishiyuanyuan;
import com.javaPro.myProject.modules.lishiyuanyuan.service.LishiyuanyuanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 历史渊源(Lishiyuanyuan)表服务实现类
 *
 * @author
 * @since 15:52:20
 */
@Service("lishiyuanyuanService")
public class LishiyuanyuanServiceImpl implements LishiyuanyuanService {
    @Resource
    private LishiyuanyuanDao lishiyuanyuanDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Lishiyuanyuan queryById(Integer id) {
        return this.lishiyuanyuanDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param lishiyuanyuan 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Lishiyuanyuan> queryByPage(Lishiyuanyuan lishiyuanyuan) {

        return this.lishiyuanyuanDao.queryAllByLimit(lishiyuanyuan);
    }

    /**
     * 新增数据
     *
     * @param lishiyuanyuan 实例对象
     * @return 实例对象
     */
    @Override
    public Lishiyuanyuan insert(Lishiyuanyuan lishiyuanyuan) {
        this.lishiyuanyuanDao.insert(lishiyuanyuan);
        return lishiyuanyuan;
    }

    /**
     * 修改数据
     *
     * @param lishiyuanyuan 实例对象
     * @return 实例对象
     */
    @Override
    public Lishiyuanyuan update(Lishiyuanyuan lishiyuanyuan) {
        this.lishiyuanyuanDao.update(lishiyuanyuan);
        return this.queryById(lishiyuanyuan.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.lishiyuanyuanDao.deleteById(id) > 0;
    }
}
